﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccessLayer;
using Common;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace VMS_Web_UI.MasterScreens
{
    public partial class MasterTypes : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["Mode"] == "Edit" && Request["Item"] != null && Request["Desc"]!=null)
            {
                txtmastertitemtype.Value = Request["Item"].ToString();
                txtmastertitemdesc.Value = Request["Desc"].ToString();
            }

            BindGrid();
           
        }

        private void BindGrid()
        {
            grdmasteritemdetails.DataSource = new Master_Item_Types_DB().GetMasterItemTypes();
            grdmasteritemdetails.DataBind();

            LogEntry objLogEntry = new LogEntry();
            objLogEntry.Message = "Sample log";
            objLogEntry.EventId = 100;
            objLogEntry.Priority = 2;
            objLogEntry.Title = "Fun";
           
            Logger.SetLogWriter(new LogWriterFactory().Create());
            Logger.Write(objLogEntry);

        }

        public string RedirectForEdit(string item,string desc)
        {
            return "MasterTypes.aspx?Mode=Edit&Item=" + item+"&Desc="+desc;

        }

        public string RedirectForDelete(string item)
        {
            return "MasterTypes.aspx?Mode=Delete&Item=" + item;

        }

     }
}